
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

///
/// text_demo.dart
///


// No MediaQuery ancestor could be found
// starting from the context that was passed to MediaQuery.of().
// This can happen because you have not added a WidgetsApp, CupertinoApp,
// or MaterialApp widget (those widgets introduce a MediaQuery),
// or it can happen if the context you use comes from a widget above those widgets.

// void main()=>runApp(const TextDemoWidget());
void main()=>runApp(const MaterialApp(home: TextDemoWidget(),));


class TextDemoWidget extends StatelessWidget {
  const TextDemoWidget({Key? key}) : super(key: key);
  static const TextStyle blackStyle = TextStyle(fontWeight: FontWeight.normal,
      fontSize: 20, color: Colors.black);
  static const TextStyle redStyle = TextStyle(fontWeight: FontWeight.bold,
      fontSize: 20, color: Colors.red);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Text Demo')),
      body: const Text.rich(
        TextSpan(
          children: <TextSpan>[
            TextSpan(text: 'welcome', style: redStyle),
            TextSpan(text: 'Android', style: blackStyle),
            TextSpan(text: '你好', style: redStyle),
            TextSpan(text: 'hello world', style: blackStyle)
          ]
        ),
        textAlign: TextAlign.center,
      ),
    );
  }
}



